package com.studentServer.controller;

import com.studentServer.bean.Notice;
import com.studentServer.dao.NoticeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/notice")
@RestController
public class NoticeController {
    @Autowired
    NoticeDao noticeDao;

    @RequestMapping("/all")
    @ResponseBody
    public Map selectAllNotice() {
        Map map = new HashMap();
        List<Notice> noticeList = noticeDao.findAll();
        if (noticeList != null) {
            map.put("success", true);
            map.put("message", "查询全部公告成功!");
            map.put("data", noticeList);
        } else {
            map.put("success", false);
            map.put("message", "查询全部公告失败!");
            map.put("data", null);
        }
        return map;
    }
}
